package com.cloud.logger.zchain.zchainserver.mongo;

import org.springframework.data.mongodb.core.MongoOperations;
import org.springframework.data.mongodb.repository.query.MongoEntityInformation;
import org.springframework.data.mongodb.repository.support.SimpleMongoRepository;
import org.springframework.data.repository.NoRepositoryBean;

import java.io.Serializable;

/**
 * User: wcy
 * Date: 2017/10/30
 * Time: 15:42
 */
@NoRepositoryBean
public class BaseMongoRepositoryImpl<T, ID extends Serializable>
        extends SimpleMongoRepository<T, ID> implements BaseMongoRepository<T,ID>{

    protected final MongoOperations mongoOperations;

    protected final MongoEntityInformation<T, ID> entityInformation;

    public BaseMongoRepositoryImpl(MongoEntityInformation<T, ID> metadata, MongoOperations mongoOperations) {
        super(metadata, mongoOperations);
        this.mongoOperations = mongoOperations;
        this.entityInformation = metadata;
    }

    protected Class<T> getEntityClass() {
        return entityInformation.getJavaType();
    }
}
